package com.swsc.ai.enums;

import lombok.Getter;

/**
 * @describe: 通用统一返回码
 * @author: 容若
 * @created: 2024-06-20 12:54
 */
public enum CommonResultCode {
    SUCCESS("200", "请求成功"),
    REPEAT_REQ("255", "请求重复"),
    DB_FAIL("256", "插入数据失败"),
    DOWNLOAD_FAIL("257", "ftp文件下载失败"),
    FAIL("258", "请求失败"),
    ERROR("999", "请求错误"),
    ERROR_SYSTEM("500", "系统错误");

    @Getter
    private final String code;
    @Getter
    private final String msg;

    private String code() {
        return this.code;
    }

    private String msg() {
        return this.msg;
    }

    CommonResultCode(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static String getResultMsg(String code) {
        CommonResultCode[] resultCodes = values();
        for (CommonResultCode resultCode : resultCodes) {
            if (resultCode.code().equals(code)) {
                return resultCode.msg();
            }
        }
        return "请求成功";
    }
}
